<div class="container_wrap">
    
    <!-- 월/일 리스트 -->
    <!-- 
    <div class="month_day">
        <span class="month_tit">7월</span>
        <?php 
        for ($i = 1; $i < 32; $i++) {
            echo '<a href="#">'.$i.'</a> ';
        }
        ?>
    </div>
     -->
     
    <nav>
        <ul class="tab">
        <?php 
        for ($i = 0, $iLen = count($aCateList); $i < $iLen; $i++) {
            $_row = $aCateList[$i];
            
            $_on = ($params['cate'] == $_row['cate_num']) ? 'class="on"' : '';
            
            echo '<li '.$_on.'><a href="/cont/?cate='.$_row['cate_num'].'">'.$_row['cate_name'].'</a></li>';
        }
        ?>
        </ul>
    </nav>
    
    <div style="margin-top:20px;">
        <?php 
        if (contCommon::isLogin() === true) {
        ?>
        <form name="regForm" id="regForm" method="post" enctype="multipart/form-data">
        <input type="hidden" name="cate" id="cate" value="<?php echo $params['cate']; ?>" />
        
        <input type="hidden" name="c" id="c" value="main" />
        <input type="hidden" name="m" id="m" value="add" />
        
            <div style="border:1px solid #ccc; width:650px; padding:5px;">
            <div style="margin-bottom:5px;"><textarea name="contents_desc" id="contents_desc" style="vertical-align:middle; border:none; width:100%; height:50px; overflow:auto; resize:none;"></textarea></div>
            <div><span id="previewImage"></span></div>
            </div>
            <?php  
            $UA = $_SERVER['HTTP_USER_AGENT'];
            // Chrome, Firefox
            if (strpos($UA, 'Chrome') !== false || strpos($UA, 'Firefox') !== false) {
            ?>
                <div style="padding-top:5px;">
                    <span class="hide" id="el_span_img">
                    <input type="file" name="uploads" id="uploads" value="" onchange="Base.previewImage(this, $('#previewImage'), 100);" class="hide" />
                    </span>
                    <button type="button" onclick="$('#uploads').click();" class="button large gray">이미지</button>
                    <a href="javascript:;" onclick="Conts.regist();" class="button middle green">게시</a>
                </div>
            <?php 
            // IE, etc
            } else {
            ?>
                <div style="padding-top:5px;">
                    <span class="hide" id="el_span_img">
                    <input type="file" name="uploads" id="uploads" value="" onchange="Base.previewImage(this, $('#previewImage'), 100);" class="input_file" />
                    </span>
                    <button type="button" onclick="if ($('#el_span_img').css('display') == 'none') { $('#el_span_img').show(); } else { $('#el_span_img').hide(); }" class="button large gray">이미지</button>
                    <a href="javascript:;" onclick="Conts.regist();" class="button middle green">게시</a>
                </div>
            <?php } ?>
        </form>
        <?php 
        } else {
            echo '<div class="center"><a href="/cont/?c=sign&m=signin" class="bold green" style="font-size:18px;">로그인</a> 하시면 글을 등록하실 수 있습니다.</div>';
        } ?>
    </div>
    
    
    <div style="margin-top:30px;">
        <table width="100%">
        <colgroup>
            <col width="100" />
            <col width="10" />
            <col width="*" />
        </colgroup>
        
        <?php
        // 컨텐츠 리스트
        $aContentsNum = array();
        for ($i = 0, $iLen = count($aContentsList); $i < $iLen; $i++) {
            $_row = $aContentsList[$i];
            
            $aContentsNum[] = $_row['contents_num'];
        ?>
        
        <tr><td colspan="3"><div class="list_line"></div></td></tr>
        
        <tr>
            <td valign="top">
                <div><img src="<?php echo contCommon::getImageUrl($aUserInfoList[$_row['user_num']]['user_photo'])?>" width="50" /></div>
                <div style="margin-top:5px;"><?php echo $aUserInfoList[$_row['user_num']]['user_name']; ?></div>
            </td>
            <td></td>
            <td valign="top">
                <div class="">
                    <?php echo nl2br(htmlspecialchars($_row['contents_desc'])); ?>
                    
                    <?php 
                    // 이미지 표시
                    if (empty($_row['contents_img']) === false) {
                        $_img = contCommon::getImageUrl($_row['contents_img'], 450);
                        echo '<div style="margin:10px 0;"><img src="'.$_img.'" /></div>';
                    }
                    ?>

                    <div style="margin-top:10px;"><?php echo date("Y.m.d H:i", $_row['reg_ts']); ?></div>
                </div>
                
                <div id="comment_list_<?php echo $_row['contents_num']; ?>" style="margin-top:10px;">
                    <table width="100%">
                    <colgroup>
                        <col width="45" />
                        <col width="1" />
                        <col width="*" />
                    </colgroup>
                    <?php 
                    for ($n = 0, $iLen2 = count($aContentsComment[$_row['contents_num']]); $n < $iLen2; $n++) {
                        $aComment = $aContentsComment[$_row['contents_num']][$n];
                    ?>
                    <tr style="background:#EFEFEF;">
                        <td valign="middle" style="padding:3px;">
                            <div><img src="<?php echo contCommon::getImageUrl($aUserInfoList[$aComment['user_num']]['user_photo'])?>" height="30" /></div>
                        </td>
                        <td></td>
                        <td valign="middle">
                            <div><span class="bold green" style="padding-right:5px;"><?php echo $aUserInfoList[$aComment['user_num']]['user_name']; ?></span> <?php echo htmlspecialchars($aComment['comment_desc']); ?></div>
                            <div><?php echo date("Y.m.d H:i", $aComment['reg_ts']); ?></div>
                        </td>
                    </tr>
                    <tr><td colspan="3"></td></tr>
                    <?php } ?>
                    </table>
                </div>
                
                <?php if (contCommon::isLogin() === true) { ?>
                <div>
                    <table width="100%">
                    <colgroup>
                        <col width="45" />
                        <col width="1" />
                        <col width="*" />
                    </colgroup>
                    <tr style="background:#EFEFEF; margin-bottom:2px;">
                        <td valign="middle" style="padding:3px;">
                            <div><img src="<?php echo contCommon::getImageUrl($_USERINfO['user_photo']); ?>" height="30" /></div>
                        </td>
                        <td></td>
                        <td valign="middle">
                            <div>
                                <form name="cmtForm" id="cmtForm_<?php echo $_row['contents_num']; ?>" method="post" onsubmit="Conts.regComment(<?php echo $_row['contents_num']; ?>); return false;">
                                <input type="text" name="comment_desc" id="comment_desc_<?php echo $_row['contents_num']; ?>" value="" class="input_text wd500" />
                                </form>
                            </div>
                        </td>
                    </tr>
                    </table>
                </div>
                <?php } ?>
                
            </td>
        </tr>
        
        <?php } ?>
      
        </table>
    </div>
    
</div>

<div>
    <?php echo $paging; ?>
</div>


<script>
<?php 
if (empty($aContentsNum) === false) {
    $sContentsNumList = implode(', ', $aContentsNum);
    
    echo 'var sContentsNumList = "'.$sContentsNumList.'";';
}
?>
</script>